﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.ComponentModel;
using Lswweb.Domain;
using Lswweb.Model;

namespace Lswweb.Controls
{
    [ParseChildren(true)]
    public class ActionBar : SkinnedWebControl
    {
        #region 成员字段和构造函数

        private ITemplate _template;
        private Control divActionBar;
        private Breadcrumb breadcrumb;
        private Label txtTitle;

        #endregion


        #region 初始化皮肤

        protected override void InitializeSkin(Control skin)
        {
            txtTitle = (Label)skin.FindControl("txtTitle");
            divActionBar = (Control)skin.FindControl("acctionBarPanel");
            breadcrumb = (Breadcrumb)skin.FindControl("breadcrumb");

            if (LinkTemplate != null)
                LinkTemplate.InstantiateIn(divActionBar);

            if (SiteContext.Current.MapNode != null)
                txtTitle.Text = SiteContext.Current.MapNode.Text;
        }

        #endregion

        [Browsable(false)]
        [TemplateContainer(typeof(ActionBar))]
        [PersistenceMode(PersistenceMode.InnerProperty)]
        public ITemplate LinkTemplate
        {
            get { return _template; }
            set { _template = value ; }
        }

        protected override string DefaultSkinFilename
        {
            get { return "ActionBar.ascx"; }
        }
    }
}